package com.os.common.support;

import com.os.crm.service.BaiduMapService;
import com.os.crm.service.GaoDeMapService;
import com.os.sys.config.MyProps;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

//测试用-可删除
@Configuration      //1.主要用于标记配置类，兼备Component的效果。
@EnableScheduling   // 2.开启定时任务
@Slf4j
public class CRMTask {
    @Value(value = "${system.path_base}")
    String pathBase;

    @Autowired
    MyProps myProps;

    @Autowired
    BaiduMapService baiduMapService;
    @Autowired
    GaoDeMapService gaoDeMapService;
    //3.添加定时任务
    //@Scheduled(cron = "0/5 * * * * ?")
    //或直接指定时间间隔，例如：50秒
    //@Scheduled(fixedRate=1800000)
    @Scheduled(fixedRate=1800000)
    private void baiDuMapTask() {
        log.info("pathBase=", myProps.path_base);

        log.info("CRMTask.baiDuMapTask::执行地图数据采集::定时任务执行时间: " + LocalDateTime.now());
        //baiduMapService.getBaiduMapData();
        //gaoDeMapService.getMapData();
        //gaoDeMapService.getCityLocation();
        log.info("CRMTask.baiDuMapTask::执行地图数据采集::定时任务执行结束时间: " + LocalDateTime.now());
        //baiduMapService.getBaiduMapData("哈尔滨","烧烤","45.759,126.660"); //finish
        //baiduMapService.getBaiduMapData("哈尔滨","串","45.759,126.660");   //finish
        //baiduMapService.getBaiduMapData("哈尔滨","火锅","45.759,126.660"); //finish
        //baiduMapService.getBaiduMapData("哈尔滨","炭","45.759,126.660"); //finish
        //baiduMapService.getBaiduMapData("哈尔滨","饭店","45.759,126.660"); //finish
        //baiduMapService.getBaiduMapData("哈尔滨","川菜","45.759,126.660"); //finish
        //baiduMapService.getBaiduMapData("哈尔滨","面馆","45.759,126.660"); //finish
        //System.out.println("com.os.common.support.SaticScheduleTask.执行静态定时任务时间: " + LocalDateTime.now());
    }
}
